In [1]:
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import os
for dirname, _, filenames in os.walk('/AICTE/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))
In [4]:
!pip install plotly

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import plotly.express as px

import warnings
warnings.filterwarnings('ignore')
Requirement already satisfied: plotly in c:\users\harsh\anaconda3\lib\site-packages (5.9.0)
Requirement already satisfied: tenacity>=6.2.0 in c:\users\harsh\anaconda3\lib\site-packages (from plotly) (8.2.2)
In [5]:
df=pd.read_csv("D:\Datasets\TrafficIndex_19Jun2022-26Jun2022.csv")
In [6]:
df.head()
Out[6]:
Rank City AverageTCI MaxTCI
0 1 Lagos 60.16 130.21
1 2 Riga 47.12 87.51
2 3 Mumbai 38.37 153.41
3 4 Tehran 38.20 110.12
4 5 London 38.16 128.50

Data Preprocessing¶

get the location data of cities

In [8]:
!pip install geopy

from geopy.geocoders import Nominatim
 
geolocator = Nominatim(user_agent="test")
 
from geopy.extra.rate_limiter import RateLimiter
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
df['location'] = df['City'].apply(geocode)
df['point'] = df['location'].apply(lambda loc: tuple(loc.point) if loc else None)
Collecting geopy
  Obtaining dependency information for geopy from https://files.pythonhosted.org/packages/e5/15/cf2a69ade4b194aa524ac75112d5caac37414b20a3a03e6865dfe0bd1539/geopy-2.4.1-py3-none-any.whl.metadata
  Downloading geopy-2.4.1-py3-none-any.whl.metadata (6.8 kB)
Collecting geographiclib<3,>=1.52 (from geopy)
  Obtaining dependency information for geographiclib<3,>=1.52 from https://files.pythonhosted.org/packages/9f/5a/a26132406f1f40cf51ea349a5f11b0a46cec02a2031ff82e391c2537247a/geographiclib-2.0-py3-none-any.whl.metadata
  Downloading geographiclib-2.0-py3-none-any.whl.metadata (1.4 kB)
Downloading geopy-2.4.1-py3-none-any.whl (125 kB)
   ---------------------------------------- 0.0/125.4 kB ? eta -:--:--
   ---------------------------------------- 0.0/125.4 kB ? eta -:--:--
   --- ------------------------------------ 10.2/125.4 kB ? eta -:--:--
   --- ------------------------------------ 10.2/125.4 kB ? eta -:--:--
   --------- ----------------------------- 30.7/125.4 kB 262.6 kB/s eta 0:00:01
   --------- ----------------------------- 30.7/125.4 kB 262.6 kB/s eta 0:00:01
   --------- ----------------------------- 30.7/125.4 kB 262.6 kB/s eta 0:00:01
   ------------------------- ------------- 81.9/125.4 kB 306.3 kB/s eta 0:00:01
   ------------------------- ------------- 81.9/125.4 kB 306.3 kB/s eta 0:00:01
   ------------------------- ------------- 81.9/125.4 kB 306.3 kB/s eta 0:00:01
   -------------------------------------  122.9/125.4 kB 300.4 kB/s eta 0:00:01
   -------------------------------------- 125.4/125.4 kB 295.4 kB/s eta 0:00:00
Downloading geographiclib-2.0-py3-none-any.whl (40 kB)
   ---------------------------------------- 0.0/40.3 kB ? eta -:--:--
   ---------------------------------------- 40.3/40.3 kB 1.9 MB/s eta 0:00:00
Installing collected packages: geographiclib, geopy
Successfully installed geographiclib-2.0 geopy-2.4.1
In [9]:
df
Out[9]:
Rank City AverageTCI MaxTCI location point
0 1 Lagos 60.16 130.21 (Lagos, Lagos Island, Lagos, 100242, Nigeria, ... (6.4550575, 3.3941795, 0.0)
1 2 Riga 47.12 87.51 (Rīga, Latvija, (56.9493977, 24.1051846)) (56.9493977, 24.1051846, 0.0)
2 3 Mumbai 38.37 153.41 (Mumbai Suburban, Maharashtra, India, (19.0549... (19.054999, 72.8692035, 0.0)
3 4 Tehran 38.20 110.12 (شهر تهران, بخش مرکزی شهرستان تهران, شهرستان ت... (35.6892523, 51.3896004, 0.0)
4 5 London 38.16 128.50 (London, Greater London, England, United Kingd... (51.4893335, -0.1440551, 0.0)
... ... ... ... ... ... ...
63 64 Singapore 5.23 42.93 (Singapore, (1.357107, 103.8194992)) (1.357107, 103.8194992, 0.0)
64 65 Helsinki 4.67 22.43 (Helsinki, Helsingin seutukunta, Uusimaa, Mann... (60.1674881, 24.9427473, 0.0)
65 66 Turin 4.29 46.20 (Torino, Piemonte, Italia, (45.0677551, 7.6824... (45.0677551, 7.6824892, 0.0)
66 67 Valencia 3.40 31.97 (València, Comarca de València, València / Val... (39.4697065, -0.3763353, 0.0)
67 68 Zaragoza 2.01 42.18 (Zaragoza, Aragón, España, (41.6521342, -0.880... (41.6521342, -0.8809428, 0.0)

68 rows × 6 columns

In [10]:
df['latitude']=df['point'].str[0]
df['longitude']=df['point'].str[1]
In [11]:
df
Out[11]:
Rank City AverageTCI MaxTCI location point latitude longitude
0 1 Lagos 60.16 130.21 (Lagos, Lagos Island, Lagos, 100242, Nigeria, ... (6.4550575, 3.3941795, 0.0) 6.455057 3.394179
1 2 Riga 47.12 87.51 (Rīga, Latvija, (56.9493977, 24.1051846)) (56.9493977, 24.1051846, 0.0) 56.949398 24.105185
2 3 Mumbai 38.37 153.41 (Mumbai Suburban, Maharashtra, India, (19.0549... (19.054999, 72.8692035, 0.0) 19.054999 72.869203
3 4 Tehran 38.20 110.12 (شهر تهران, بخش مرکزی شهرستان تهران, شهرستان ت... (35.6892523, 51.3896004, 0.0) 35.689252 51.389600
4 5 London 38.16 128.50 (London, Greater London, England, United Kingd... (51.4893335, -0.1440551, 0.0) 51.489334 -0.144055
... ... ... ... ... ... ... ... ...
63 64 Singapore 5.23 42.93 (Singapore, (1.357107, 103.8194992)) (1.357107, 103.8194992, 0.0) 1.357107 103.819499
64 65 Helsinki 4.67 22.43 (Helsinki, Helsingin seutukunta, Uusimaa, Mann... (60.1674881, 24.9427473, 0.0) 60.167488 24.942747
65 66 Turin 4.29 46.20 (Torino, Piemonte, Italia, (45.0677551, 7.6824... (45.0677551, 7.6824892, 0.0) 45.067755 7.682489
66 67 Valencia 3.40 31.97 (València, Comarca de València, València / Val... (39.4697065, -0.3763353, 0.0) 39.469707 -0.376335
67 68 Zaragoza 2.01 42.18 (Zaragoza, Aragón, España, (41.6521342, -0.880... (41.6521342, -0.8809428, 0.0) 41.652134 -0.880943

68 rows × 8 columns

In [12]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 68 entries, 0 to 67
Data columns (total 8 columns):
 #   Column      Non-Null Count  Dtype  
---  ------      --------------  -----  
 0   Rank        68 non-null     int64  
 1   City        68 non-null     object 
 2   AverageTCI  68 non-null     float64
 3   MaxTCI      68 non-null     float64
 4   location    68 non-null     object 
 5   point       68 non-null     object 
 6   latitude    68 non-null     float64
 7   longitude   68 non-null     float64
dtypes: float64(4), int64(1), object(3)
memory usage: 4.4+ KB

Average TCI¶

Top 10 cities

In [13]:
df.sort_values(by="AverageTCI",ascending=True).tail(10).plot.barh(x='City',y='AverageTCI')
Out[13]:
<Axes: ylabel='City'>

Global map of average TCI

In [14]:
fig = px.scatter_mapbox(df,lat='latitude',lon='longitude',hover_name='City',hover_data=['AverageTCI'],color='AverageTCI',
    size="AverageTCI",size_max=20,opacity=0.4,
    center={'lat':50, 'lon':9},
    zoom=1,
    height=700,
    width=1000)
fig.update_layout(mapbox_style='open-street-map')
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.update_layout(title_text="City Map for Average TCI")
fig.show()

Case Study1: Lagos

Lagos is the highest in AverageTCI. What is happening in Lagos ?

I found the article 'Trafic Lagos Congestion in Lagos' ( https://www.internetgeography.net/topics/traffic-congestion-in-lagos/ ).

According to the article,

1.WHAT IMPACT DOES TRAFFIC CONGESTION HAVE ON PEOPLE IN LAGOS?

Lagos is one of the most congested cities in the world. 40 per cent of cars in Nigeria are registered in Lagos. Commuters spend at least three hours in traffic each day. Traffic congestion leads to many problems for the residents of Lagos. For example, the fatal accident rate in Lagos is 28 per 100,000 people. This is three times greater than in most European cities. Also, air pollution is over 5 times greater than the recommended limit.

2.WHAT EFFORTS HAVE BEEN MADE TO REDUCE TRAFFIC CONGESTION?

The Lagos Metropolitan Area Transport Authority (LAMATA) was set up by the Lagos state government in 2003 to improve transport in the city. The Authority set up a bus rapid transit (BRT) system that runs from north-south from the suburbs to the CBD on Lagos Island. The system provides a dedicated land for buses. Over 200,000 people use the system each day. The public transport system is supported by a large fleet of minibus taxis called ‘danfos’. These buses are designed to carry ten to fifteen people but often carry more.

3.HOW COULD A TRANSPORT MASTER PLAN HELP LAGOS?

A new light railway scheme is being developed in Lagos. The first stage of the Lagos Rail Mass Transit (LRMT) opened in 2016 and runs from a west-east route into the CBD. The system carries seven times as many passengers as the BRT. There are plans to develop the network to incorporate seven further rail lines. This is part of a wider Strategic Transport Master Plan for Lagos which includes:

an integrated transport system that links road, rail and waterway networks;

a waterway network of ferries making use of the water around Lagos;

a road network with separate bus lanes;

a new airport further away from the urban environment;

the development of mixed-use urban developments combining residential and commercial areas to reduce the number of journeys people need to make;

better walking and cycling facilities.

reference : 'Trafic Lagos Congestion in Lagos' ( https://www.internetgeography.net/topics/traffic-congestion-in-lagos/ )

Max TCI¶

Top 10 cities

In [15]:
df.sort_values(by="MaxTCI",ascending=True).tail(10).plot.barh(x='City',y='MaxTCI')
Out[15]:
<Axes: ylabel='City'>

Global map of Max TCI

In [16]:
fig = px.scatter_mapbox(df,lat='latitude',lon='longitude',hover_name='City',hover_data=['MaxTCI'],color='MaxTCI',
    size="MaxTCI",size_max=20,opacity=0.4,
    center={'lat':50, 'lon':9},
    zoom=1,
    height=700,
    width=1000)
fig.update_layout(mapbox_style='open-street-map')
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.update_layout(title_text="City Map for Max TCI")
fig.show()

Case Study2: Istanbul

Istanbul is the highest in MaxTCI. What is happening in Istanbul ?

I found the article 'WORLD DESIGN TALKS TRAFFIC CONGESTION - ISTANBUL REPORT' ( https://wdo.org/programmes/wd-talks/traffic-congestion/ ).

According to the article,

Fuelled by the desire for a better quality of life (whether due to poverty, rural unemployment, conflict), people are flooding into urban areas at an unprecedented rate. Rapid urbanization may help lift standards of living, but it also puts a tremendous strain on city services, such as housing, education, health care and transportation.

One of the fastest growing cities in the world with a population of 14 million, Istanbul was not created with modern transport in mind, and its infrastructure is unable to keep up with the demands of a growing population, estimated to reach an unsustainable 20-22 million by 2020. This megacity is the third most congested, after Mexico and Bangkok, with a 50% increase in travel times when compared to free flow traffic (TomTom’s 2016 Traffic Index).

The causes of traffic congestion in Istanbul are numerous and include poorly planned roadways and transportation systems, poorly timed traffic signals, insufficient traffic system coordination, traffic accidents, special events (ex: concerts, festivals), and the unexploited use of Istanbul’s seaways and sea transportation.

According to Prof. Dr. Murat Çelik of Istanbul Technical University, traffic congestion costs Istanbul more than 3 billion Turkish Liras per year due to loss of labour and excess fuel consumption, just about equal to Turkey’s GDP.

Reducing traffic congestion would address various targets set by the UN Sustainable Development Goals, helping to reduce greenhouse gas emissions and to improve air quality, a major health problem in most megacities.

REDUCING TRAFFIC CONGESTION: SHORT, MID AND LONG TERM SOLUTIONS Short-term solutions

Encourage sustainable transportation through public transportation, and incentivize people to use public transportation with economical fares that are socially equitable and accessible for all. Public transport improvements would also include automatic vehicle licensing and real time arrival information. Implement congestion pricing; price according to the number of people in a car and the time of day (toll for people who travel to town during high peak times; high parking fares can discourage people from using their cars downtown)

Mid-term solutions

Facilitate travel demand management by: Stuttering travel times Encouraging businesses to adopt telecommuting (working from home) Encouraging car-free zones, pedestrians, bicycle use and better pedestrian/bicycle connections Improving land use through smart growth policies (non-dense settlements and exclusive zoning) Designing transit strategies that encourage people to use high occupancy vehicles and public transportation. Use technology (such as GPS, digital maps) to help educate citizens and help them make better transportation choices. Digital platforms (apps) can also help to better integrate the transportation system so that citizens can plan their trips in real time. Transform culture, attitudes, and behaviours with regard to transportation. Pedestrianize the inner city to transform the human experience in downtown Istanbul and improve quality of life. Incorporate intelligent route finding to free up urban space for such activities as strolling around and communication. Add electronic or hybrid cars to the fleet of dolmuş to help alleviate greenhouse gas emissions.

Long-term solutions

Link rail, road and water transport on the one hand and public and private means of transport on the other. Create a sea dolmuş Improve roadway security design; barriers on shoulders, curbs, roundabouts, advanced signal systems, lane restrictions for high occupancy vehicles (ex: bus lanes) and changeable lane allocation can help calm and manage traffic. Involve designers in the management and planning of an integrated transportation system. Designers have a unique mindset for solving problems that is distinct from traditional methods of urban planning, industrial design places the needs and experiences of human beings first when designing out traffic congestion.

reference: 'WORLD DESIGN TALKS TRAFFIC CONGESTION - ISTANBUL REPORT' ( https://wdo.org/programmes/wd-talks/traffic-congestion/ ).

Insight¶

Both cities, Lagos and Istanbul have about 15 million population and are growing rapidly.

Lagos:Population image.png

Istanbul: Population image.png

As I can see in the case study of Istanbul, its infrastructure is unable to keep up with the demands of a growing population. The causes of traffic congestion in Istanbul are numerous and include poorly planned roadways and transportation systems, poorly timed traffic signals, insufficient traffic system coordination, traffic accidents, special events (ex: concerts, festivals), and the unexploited use of Istanbul’s seaways and sea transportation. It may be same in Lagos. Implement congestion pricing; price according to the number of people in a car and the time of day will be useful to reduce congestion. But we have to consider long term solution to reduce not only congestion but also CO2 emissions.

In [17]:
df[df['City']=='Tokyo']
Out[17]:
Rank City AverageTCI MaxTCI location point latitude longitude
49 50 Tokyo 10.03 72.61 (東京都, 日本, (35.6768601, 139.7638947)) (35.6768601, 139.7638947, 0.0) 35.67686 139.763895

For example, AverageTCI of Tokyo is 10.03. And population of Tokyo which includes metro area is image.png

(data from microtrend https://www.macrotrends.net/cities/22691/istanbul/population )

It seems to pass the peak.

And I also found the academic paper ,"Traffic Jams in Japan: does public transit have an impact?" by Gordon Heaton, UC Berkeley Economics Department, which gives me some tips. (https://www.econ.berkeley.edu/sites/default/files/Heaton.pdf)

In this paper, we can find that the length of rail does appear to have an ameliorating effect on road performance, measured by average road speed. Actually, around Tokyo, we have a lot of organized railway.

image.png

At rush hour in the morning and evening, we are still suffering from a lot of people in the train, but it may help for us to reduce the congestion and CO2 emissions...

In [ ]: